{if !$ajax}
{include file="header.inc.html"}
<style>
.sub{
	text-indent:30px;
}
.toggle,.editop{
	cursor:pointer;
}
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
	  {include file="left.inc.html"}  
	  <div class="layui-body">
		<!-- 内容主体区域 -->
		<div style="padding: 15px;">


			<div class="layui-breadcrumb">
			 {include file="where.inc.html"}
			</div>
			{/if}
<div id="main_table_id">
		<table lay-filter="main_table_" class="layui-table">
		  <colgroup>
			<col width="160">
			<col width="150">
			<col width="80">
			<col width="60">
			<col width="60">
			<col width="200">
			<col>
		  </colgroup>
		<thead>
		<tr>
			<th>唯一标识</th>
			<th>模块名称</th>
			<th>作者/显示菜单</th>
			<th>状态</th>
			<th>排序</th>
			<th>操作</th>
		</tr>
		</thead>
		{foreach $rs as $k => $v}
		<tr dataid="{$v.module}">
			<td class="toggle" dataid="{$v.module}" title="{$v.tag}">{$v.module}
			{if isset($ops[$v['module']])} <span class="layui-badge">{:count($ops[$v['module']])}</span>
			{/if}</td>
			<td class="fast"  datafield="name" title="{$v.desc}">{$v.name}</td>

			<td class="fast" datafield="auth">{$v.auth}</td>
			<td class="fast" datafield="status">{$v.status}</td>
			<td class="fast" datafield="porder">{$v.porder}</td>
			<td dataid="{$v.module}">
  <a class="layui-btn layui-btn-mini add_op " lay-event="detail">添加操作</a>
  <a class="layui-btn layui-btn-mini edit " lay-event="edit">编辑模块</a>

  <a class="layui-btn layui-btn-danger layui-btn-mini auto_implode" lay-event="">自动导入</a>

  <a class="layui-btn layui-btn-danger layui-btn-mini del" lay-event="del">{$ICON.del}删除</a> 
		</tr>


			{if isset($ops[$v['module']])}
			<tbody  class="subtr_{$v.module}" {if !$v['show_sub']} style="display:none"{/if}>
			{foreach $ops[$v['module']] as $kk => $vv}
				<tr dataid="{$vv.id}">
					<td class="sub editop">|---{$vv.method}{if $vv.is_menu}<span class="layui-badge" style="text-indent:0px;">m</span>{/if}
					
					{if !$vv.is_admin}<span class="layui-badge" style="text-indent:0px;">前台</span>{/if}</td>
					<td class="sub fastop" datafield="name">{$vv.name}</td>
					
					<td class="sub fastop" datafield="is_menu">{$vv.is_menu}</td>
					<td class="fastop" datafield="status">{$vv.status}</td>
					<td  class="sub fastop" style="" datafield="porder">{$vv.porder} </td>
					<td dataid="{$vv.id}">
		  <a class="layui-btn layui-btn-mini editop" lay-event="edit">{$ICON.edit}编辑</a>
		  <a class="layui-btn layui-btn-danger layui-btn-mini delop" lay-event="del">{$ICON.del}删除</a>  </td>
				</tr>
			{/foreach}
			</tbody>
			{/if}
		{/foreach}

</table></div>


{if $ajax}

<script>
myinit();
</script>
{/if}



{if !$ajax}

			<button class="layui-btn layui-layout-rightxx icon_add" id="add_moudle">添加模块</button>
			<button class="layui-btn layui-btn-normal" id="add_moudle">导出模块</button>
			<button class="layui-btn layui-btn-normal" id="add_moudle">导入模块</button>
			{**###################################################**}
			
		</div>	
	  </div><!-- /layui-body -->


<script>

var myinit = function(){
	$ = layui.$ ;
	$.each($('.add_op'),function(){		
	$(this).click(function(){
		openPage('{_url m="addop"}&module='+$(this).parent().attr('dataid'),'添加模块'+$(this).attr('data')+'下的操作');
		});
	});

	$.each($('.edit'),function(){		
		$(this).click(function(){
			openPage('{_url m="edit"}&module='+$(this).parent().attr('dataid'),'编辑模块');
		});
	});
	

	$.each($('.del'),function(){		
		$(this).click(function(){
			url = '{_url m="dodel"}&module='+$(this).parent().attr('dataid')+"&t="+Math.random();
			myconfirm(url);
		});
	});
	$.each($('.delop'),function(){		
		$(this).click(function(){
			url = '{_url m="dodeleteop"}&id='+$(this).parent().attr('dataid')+"&t="+Math.random();
			myconfirm(url);
		});
	});
	$.each($('.toggle'),function(){
		$(this).click(function(){
			class_id = $(this).attr('dataid');
			$('.'+"subtr_" + class_id).toggle('fast', function(obj){
				url = '{_url m="index" toggle=1}&data='+class_id+"|"+$(this).css('display')+"&t="+Math.random();
				$.get(url);
			});
		});
	});
	$.each($('.editop'),function(){		
		$(this).click(function(){
			openPage('{_url m="editop"}&id='+$(this).parent().attr('dataid'),'编辑操作');
		});
	});
	$.each($('.auto_implode'),function(){		
		$(this).click(function(){
			url = '{_url m="autoimplode"}&id='+$(this).parent().attr('dataid')+"&t="+Math.random();
			myconfirm(url,"您确定要导入此类下的操作吗?");
		});
	});
	
	fastEdit2('{_url m="fast"}','fast');
	fastEdit2('{_url m="fastop"}','fastop');


};

layui.use(['table','layer'], function(){
  var table = layui.table, $ = layui.$ , layer = layui.layer;

  doFastEdit('{_url m="fast"}', 'main_table');
	/*绑定EDIT操作*/
	$('#add_moudle').click(function(){		
		openPage('{_url m="add"}','添加模块');			
	});
	myinit();

	
});

/*<input type="checkbox" name="status" value=1 checked lay-skin="switch">*/
</script>
{html}
<script type="text/html" id="statusTpl">
 {{# if (d.status == 1) { }}		
		开启
	{{#  } else { }}
		关闭
	 {{#  } }}
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-mini view" lay-event="detail" data="{{d.id}}">查看</a>
  <a class="layui-btn layui-btn-mini add_op" lay-event="detail" data="{{d.id}}">添加操作</a>
  <a class="layui-btn layui-btn-mini edit" lay-event="edit" data="{{d.id}}">编辑模块</a>
  <a class="layui-btn layui-btn-danger layui-btn-mini del" data="{{d.id}}" lay-event="del">删除</a>  

</script>

{/html}
{include file="footer.inc.html"}



{/if}















{**以下为历史模板,可用于其它页面*}
{if $ajax == 555}

<?php
ob_start();
?>

{"code":0,"msg":"","count":1000,"data":[

{foreach $rs as $k => $v}

				{"id":"{$v.id}","name":"<a href='#' class=view>{$v.name}</a>"
				,"desc":"{$v.desc}","auth":"{$v.auth}","porder":"{$v.porder}"
				,"status":"{$v.status}"},
				{/foreach}

<?php
$a = trim(ob_get_contents());
ob_clean();
echo substr($a,0,-1);
?>

]}



{**{"id":10000,"username":"user-0","sex":"女","city":"城市-0","sign":"签名-0","experience":255,"logins":24,"wealth":82830700,"classify":"作家","score":57}
*}
<?php exit;?>

{include file="header.inc.html"}

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
	  {include file="left.inc.html"}  
	  <div class="layui-body">
		<!-- 内容主体区域 -->
		<div style="padding: 15px;">


			<div class="layui-breadcrumb">
			  <a href="{url }">首页</a>
			  <a href="{url c='develop'}">核心管理</a>
			  <a><cite>模块管理</cite></a>
			</div>
			
	<table lay-filter="main_table" class="layui-table" id="main_table">
 
</table>
			<button class="layui-btn layui-layout-rightxx" id="add_moudle">添加模块</button>
			{**###################################################**}
			
		</div>	
	  </div><!-- /layui-body -->


<script>
layui.use(['table','layer'], function(){
  var table = layui.table, $ = layui.$ , layer = layui.layer;
	/*  //转换静态表格
	table.init('demo', {	
	  //支持所有基础参数
	}); 
	*/
	/*输出*/
	var tableIns = table.render({
		elem:'#main_table',
		cols:  [[ 
    {checkbox: true}
    ,{field: 'id', title: '唯一标识', width: 100,sort:true}
    ,{field: 'name', title: '模块名称', width: 120,sort:true,edit:'text'}

    ,{field: 'desc', title: '描述', width: 300,edit:'text'}
    ,{field: 'auth', title: '作者', width: 100,edit:'text'}
    ,{field: 'status', title: '状态', width: 80,sort:true,edit:'text', templet: '#statusTpl'}
	 ,{field: 'porder', title: '排序', width: 80,edit:'text',sort:true}
    ,{field: 'op', title: '操作', width: 300, toolbar: '#barDemo'}
  ]],
		
		url : '{_url ajax=1}',
		done : function(){
			$.each($('.add_op'),function(){		
		$(this).click(function(){
			openPage('{_url m="addop"}&id='+$(this).attr('data'),'添加模块'+$(this).attr('data')+'下的操作');
			});
		});

		$.each($('.edit'),function(){		
			$(this).click(function(){
				openPage('{_url m="edit"}&id='+$(this).attr('data'),'编辑模块');
			});
		});
		$.each($('.view'),function(){		
			$(this).click(function(){

				openPage('{_url m="view"}&id='+$(this).attr('data'),'查看模块');
			});
		});

		$.each($('.del'),function(){		
			$(this).click(function(){
				url = '{_url m="dodel"}&id='+$(this).attr('data')+"&t="+Math.random();
				myconfirm(url);
			});
		});
		},
		data : [
			{foreach $rs as $k => $v}
				{'id':'{$v.id}','name':'<a href="#" class=view>{$v.name}</a>'
				,'desc':'{$v.desc}','auth':'{$v.auth}','porder':'{$v.porder}'
				,'status':'{$v.status}'},
				/*
				{if isset($ops[$v['id']])}
				{foreach $ops[$v['id']] as $kk => $vv}
					{'id':'{$v.id}','name':'{$v.name}','desc':'{$v.desc}','auth':'{$v.auth}','porder':'{$v.porder}','status':'{$v.status}'},

								
				{/foreach}
				{/if}
				*/

			{/foreach}
		],		
	});

	doFastEdit('{_url m="fast"}', 'main_table');
	/*绑定EDIT操作*/
	$('#add_moudle').click(function(){		
		openPage('{_url m="add"}','添加模块');			
	});
	/*
	$.each($('.add_op'),function(){		
		$(this).click(function(){
			openPage('{_url m="addop"}&id='+$(this).attr('data'),'添加模块'+$(this).attr('data')+'下的操作');
		});
	});

	$.each($('.edit'),function(){		
		$(this).click(function(){
			openPage('{_url m="edit"}&id='+$(this).attr('data'),'编辑模块');
		});
	});
	$.each($('.view'),function(){		
		$(this).click(function(){
			openPage('{_url m="view"}&id='+$(this).attr('data'),'查看模块');
		});
	});

	$.each($('.del'),function(){		
		$(this).click(function(){
			url = '{_url m="dodel"}&id='+$(this).attr('data')+"&t="+Math.random();
			myconfirm(url);
		});
	});
	*/


	
});

/*<input type="checkbox" name="status" value=1 checked lay-skin="switch">*/
</script>
{html}
<script type="text/html" id="statusTpl">
 {{# if (d.status == 1) { }}		
		开启
	{{#  } else { }}
		关闭
	 {{#  } }}
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-mini view" lay-event="detail" data="{{d.id}}">查看</a>
  <a class="layui-btn layui-btn-mini add_op" lay-event="detail" data="{{d.id}}">添加操作</a>
  <a class="layui-btn layui-btn-mini edit" lay-event="edit" data="{{d.id}}">编辑模块</a>
  <a class="layui-btn layui-btn-danger layui-btn-mini del" data="{{d.id}}" lay-event="del">删除</a>  

</script>

{/html}
{include file="footer.inc.html"}

{/if}


